home *** CD-ROM | disk | FTP | other *** search
- /* atari.trm
- *
- * VDI based graphics driver for gnuplot 2
- *
- * Written by Jens Tingleff, placed in the public domain, use at own
- * risk.
- *
- * Slightly inspired by the driver written by
- * Joerg Heitkoetter
- * (heitkoet@lumpi.informatik.uni-dortmund.de).
- */
- #include <osbind.h>
- #include <aesbind.h>
- #include <vdibind.h>
-
- #define ST_TERM_NAME "atari"
-
- /* line styles courtesy by SUN driver */
- static unsigned
- int atari_styles[] = { 0xffff,0x1111,
- 0xffff,0x5555,0x3333,0x7777,0x3f3f,0x0f0f,0x5f5f };
-
- #define SYS_STYLES 2 /* used by Gnuplot */
- #define MAX_STYLES 9 /* all styles */
- #define USR_STYLES (MAX_STYLES-SYS_STYLES) /* for user */
-
-
- #define ST_VTIC 8
- #define ST_HTIC 6
-
- static char st_gotocmdln[128];
- static int st_vdihandle;
- static int st_workout[57];
- static enum JUSTIFY st_text_just = CENTRE;
- static int st_lastx, st_lasty, st_text_ang;
- static int st_xlast, st_ylast, st_hchar, st_vchar;
-
-
- ST_init()
- {
- int dummy, intin[11], i, phys_handle,
- n_rows, n_cols, attrib[10];
-
- phys_handle = graf_handle(&dummy, &dummy, &dummy, &dummy);
- for(i=0; i<10; i++)
- {
- intin[i] = 1;
- }
- intin[10] = 2;
- st_vdihandle = phys_handle;
- v_opnvwk(intin, &st_vdihandle, st_workout);
-
- vq_chcells(st_vdihandle, &n_rows, &n_cols);
- st_xlast = st_workout[0];
-
- /* Space for one line of console chars (not graphics text). */
- st_ylast = st_workout[1] - (st_workout[1] + 1)/n_rows;
-
- vqt_attributes(st_vdihandle, attrib);
- st_hchar = attrib[8]; /* Cell dimensions. */
- st_vchar = attrib[9];
-
- for(i=0; strcmp(term_tbl[i].name, ST_TERM_NAME) != 0; i++) /* Find */
- {
- /* nil */
- }
-
- term_tbl[i].xmax = st_xlast;
- term_tbl[i].ymax = st_ylast;
- term_tbl[i].h_char = st_hchar;
- term_tbl[i].v_char = st_vchar;
- sprintf(st_gotocmdln, "\033Y%c%c", 32+(n_rows-1), 32);
- printf("Set terminal \"%s\" to: xmax = %d, ymax = %d, "
- "h_char = %d, v_char = %d\n", term_tbl[i].name,
- term_tbl[i].xmax, term_tbl[i].ymax, term_tbl[i].h_char,
- term_tbl[i].v_char);
- }
-
-
- ST_graphics()
- {
- int array[4];
-
- fflush(stdout);
- v_clrwk(st_vdihandle);
- array[0] = array[1] = 0;
- array[2] = st_xlast;
- array[3] = st_ylast;
- vs_clip(st_vdihandle, 1, array);
-
- Cursconf(0, 0); /* Hide cursor. */
- Cconws(st_gotocmdln);
- vsl_type(st_vdihandle, 7); /* User defined. */
- ST_justify_text(CENTRE);
- }
-
-
- ST_text()
- {
- Cconws(st_gotocmdln);
- Cursconf(1, 0); /* Showcursor. */
- }
-
-
- ST_linetype(linetype)
- int linetype;
- {
- if (linetype >= 0)
- linetype %= USR_STYLES;
- vsl_udsty(st_vdihandle, atari_styles[linetype + SYS_STYLES]);
- }
-
-
- ST_move(x,y)
- int x,y;
- {
- st_lastx = x;
- st_lasty = (st_ylast - y) % (st_ylast+1);
- }
-
-
- ST_vector(x,y)
- int x,y;
- {
- int array[4];
-
- array[0] = st_lastx;
- array[1] = st_lasty;
- st_lastx = x;
- st_lasty = (st_ylast - y) % (st_ylast+1);
- array[2] = st_lastx;
- array[3] = st_lasty;
- v_pline(st_vdihandle, 2, array);
- }
-
- ST_justify_text(mode)
- int mode;
- {
- int hout, vout;
-
- /* Second param. to vst_alignment sets the vertical alignment to */
- /* be half. */
- switch(mode)
- {
- case LEFT:
- st_text_just = LEFT;
- vst_alignment(st_vdihandle, 0, 1, &hout, &vout);
- break;
- case RIGHT:
- st_text_just = RIGHT;
- vst_alignment(st_vdihandle, 2, 1, &hout, &vout);
- break;
- case CENTRE:
- st_text_just = CENTRE;
- vst_alignment(st_vdihandle, 1, 1, &hout, &vout);
- }
- return TRUE;
- }
-
- ST_text_angle(ang)
- int ang;
- {
- st_text_ang = ang;
- vst_rotation(st_vdihandle, (ang == 0 ? 0 : 900));
- return TRUE;
- }
-
-
- ST_put_text(x, y, str) /* x,y graphics coords. */
- int x, y;
- char *str;
- {
- v_gtext(st_vdihandle, x, (st_ylast - y) % (st_ylast + 1), str);
- } /* END of ST_put_text */
-
-
- ST_reset()
- {
- int array[4];
-
- array[0] = array[1] = 0;
- array[2] = st_xlast;
- array[3] = st_ylast;
-
- v_clsvwk(st_vdihandle);
- Cconws(st_gotocmdln);
- vs_clip(st_vdihandle, 0, array);
-
- }
-
-
-